package com.techstar.ats.codec.live.encoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.DateTimeCodec;
import com.techstar.ats.codec.MessageEncoder;
import com.techstar.ats.dxp.history.req.F12ReportAsk;

public enum F12ReportAskEncoder implements MessageEncoder<F12ReportAsk> {
	INSTANCE;

	public void encodeBody(ByteBuf buf, F12ReportAsk value) {
		buf.writeShort(value.line);
		buf.writeShort(value.report);
		buf.writeShort(value.type.value());
		switch(value.type) {
			case DRIVER_DISTANCE:
			case SCHEDULE_LOG:
				DateTimeCodec.INSTANCE.encode(buf, value.dateTime);
				break;
			default:
				buf.writeBytes(new byte[7]);
		}

		buf.writeBytes(new byte[7]);
	}

	public int bytes(F12ReportAsk value) {
		return 20;
	}
}
